 

function inspectContentCtrl($scope, $http, ngDialog, paFetchService, ngDialogProblem) {
  'ngInject';

  // 查询条件的对象
  this.queryData = {
  	queryType: 1,//pc:0,app:1
  };

  // 分页
  this.paginationData = {
    pageNum: 0,
    pageSize: 10,
    total: '',
  }

  // 页码变化时调用方法
  $scope.pageChange = () => {
  	this.paginationData1 = {
  	  pageNum: this.paginationData.pageNum-1,
  	  pageSize: 10,
  	  total: '',
  	}

    $http.post(`${SERVER_CONTEXT}/api/checkRecord/app/queryCheckProblemListByCondition`,
      angular.extend(this.queryData, this.paginationData1)
        )
      .then((resp) => {
        this.inspectContentList = resp.data.data;
        this.paginationData.total = resp.data.total;
    });
  };

  // 分页查询方法
  this.paginationQuery = () => {
    $http.post(`${SERVER_CONTEXT}/api/checkRecord/app/queryCheckProblemListByCondition`,
      angular.extend(this.queryData, this.paginationData)
        )
      .then((resp) => {
        this.inspectContentList = resp.data.data;
        this.paginationData.total = resp.data.total;
    });
  };

  this.paginationQuery();

  // 重置
  this.reset = () => {
    this.queryData = {
    	queryType: 0,
    };
  }

  // 查询
  this.query = (param) => {
  	if(param.endTime.$viewValue && param.startTime.$viewValue){
  	  if (param.startTime.$viewValue < param.endTime.$viewValue) {
  	    this.paginationQuery();
  	} else {
  	    layer.alert('巡查提交开始时间应小于结束时间');
  	  }
  	} else {
  	  this.paginationQuery();
  	}
  }

  // 查看内容详情
  this.checkDetail = (id) => {
    ngDialogProblem
      .confirm(id)
      .then((resolve) => {
        this.paginationQuery();
      });
  }

  // 删除巡查内容列表
  this.deleteInspectContent = (id) => {
    $scope.modalTitle = '删除巡查内容';
    $scope.modalContent = '确认要删除该信息吗?';
    ngDialog.openConfirm({
      template: 'paConfirm',
      className: 'ngdialog-theme-default pa-confirm-theme',
      scope: $scope,
    }).
      then((value) => {
        $http.delete(`${SERVER_CONTEXT}/api/securityActivities/checkProblem/deleteCheckProblem/${id}`).
          then((resp) => {
            if (resp.data.success) {
              layer.msg(resp.data.message);
              $state.reload();
            } else {
              layer.alert(resp.data.message);
            }
          });
      }, (reason) => {});
  }


}

export default inspectContentCtrl;